home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / fs.h,v < prev    next >
Encoding:
Text File  |  1991-12-11  |  29.7 KB  |  1,121 lines

  1. head     1.21;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.20.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.21
  10. date     91.12.04.14.27.03;  author jhh;  state Exp;
  11. branches ;
  12. next     1.20;
  13.  
  14. 1.20
  15. date     91.05.20.17.32.40;  author kupfer;  state Exp;
  16. branches 1.20.1.1;
  17. next     1.19;
  18.  
  19. 1.19
  20. date     90.10.11.18.55.01;  author rab;  state Exp;
  21. branches ;
  22. next     1.18;
  23.  
  24. 1.18
  25. date     90.09.13.11.10.03;  author jhh;  state Exp;
  26. branches ;
  27. next     1.17;
  28.  
  29. 1.17
  30. date     90.05.03.13.03.02;  author rab;  state Exp;
  31. branches ;
  32. next     1.16;
  33.  
  34. 1.16
  35. date     90.02.20.18.13.46;  author jhh;  state Exp;
  36. branches ;
  37. next     1.15;
  38.  
  39. 1.15
  40. date     90.01.16.17.57.38;  author brent;  state Exp;
  41. branches ;
  42. next     1.14;
  43.  
  44. 1.14
  45. date     89.11.09.13.27.41;  author shirriff;  state Exp;
  46. branches ;
  47. next     1.13;
  48.  
  49. 1.13
  50. date     89.08.30.08.21.09;  author brent;  state Exp;
  51. branches ;
  52. next     1.12;
  53.  
  54. 1.12
  55. date     89.07.18.13.54.41;  author jhh;  state Exp;
  56. branches ;
  57. next     1.11;
  58.  
  59. 1.11
  60. date     89.07.10.14.27.05;  author nelson;  state Exp;
  61. branches ;
  62. next     1.10;
  63.  
  64. 1.10
  65. date     89.06.23.11.29.42;  author rab;  state Exp;
  66. branches ;
  67. next     1.9;
  68.  
  69. 1.9
  70. date     89.06.08.12.49.44;  author brent;  state Exp;
  71. branches ;
  72. next     1.8;
  73.  
  74. 1.8
  75. date     89.04.09.10.20.30;  author brent;  state Exp;
  76. branches ;
  77. next     1.7;
  78.  
  79. 1.7
  80. date     89.02.27.17.51.45;  author mgbaker;  state Exp;
  81. branches ;
  82. next     1.6;
  83.  
  84. 1.6
  85. date     88.10.14.10.24.35;  author brent;  state Exp;
  86. branches ;
  87. next     1.5;
  88.  
  89. 1.5
  90. date     88.09.30.08.29.07;  author brent;  state Exp;
  91. branches ;
  92. next     1.4;
  93.  
  94. 1.4
  95. date     88.08.12.16.03.37;  author brent;  state Exp;
  96. branches ;
  97. next     1.3;
  98.  
  99. 1.3
  100. date     88.06.27.14.51.18;  author ouster;  state Exp;
  101. branches ;
  102. next     1.2;
  103.  
  104. 1.2
  105. date     88.06.21.16.38.46;  author ouster;  state Exp;
  106. branches ;
  107. next     1.1;
  108.  
  109. 1.1
  110. date     88.06.21.09.36.51;  author ouster;  state Exp;
  111. branches ;
  112. next     ;
  113.  
  114. 1.20.1.1
  115. date     91.08.05.17.28.29;  author kupfer;  state Exp;
  116. branches ;
  117. next     ;
  118.  
  119.  
  120. desc
  121. @@
  122.  
  123.  
  124. 1.21
  125. log
  126. @added IOC_READ and IOC_WRITE flags to those for IOC_GET_FLAGS and 
  127. IOC_SET_FLAGS
  128. @
  129. text
  130. @/*
  131.  * fs.h --
  132.  *
  133.  *    Definitions and types used in the user's interface to
  134.  *    the filesystem.
  135.  *
  136.  * Copyright 1985, 1988 Regents of the University of California
  137.  * Permission to use, copy, modify, and distribute this
  138.  * software and its documentation for any purpose and without
  139.  * fee is hereby granted, provided that the above copyright
  140.  * notice appear in all copies.  The University of California
  141.  * makes no representations about the suitability of this
  142.  * software for any purpose.  It is provided "as is" without
  143.  * express or implied warranty.
  144.  *
  145.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.20 91/05/20 17:32:40 kupfer Exp Locker: jhh $ SPRITE (Berkeley)
  146.  */
  147.  
  148. #ifndef _FS_H
  149. #define _FS_H
  150.  
  151. #include <spriteTime.h>
  152. #include <kernel/procTypes.h>
  153.  
  154. /*
  155.  * The macros major and minor are defined in sys/types.h.  They are also
  156.  * the names of fields in a structure defined in fs.h.  Only gcc and ANSI
  157.  * C are clever enough to handle this.  (The field name isn't followed
  158.  * by an open paren...)  So, if you include this file and <sys/types.h>
  159.  * then you can use the major() and minor() macros.  However, <sys/types.h>
  160.  * also defines unix_major() and unix_minor, so you can use those.
  161.  */
  162. #ifndef __STDC__ 
  163. #ifdef major
  164. #undef    major
  165. #endif
  166. #ifdef minor 
  167. #undef    minor
  168. #endif 
  169. #endif /* ! __STDC__ */
  170.  
  171. /*
  172.  * Global constants.
  173.  * FS_BLOCK_SIZE - the size of filesystem blocks
  174.  * FS_MAX_PATH_NAME_LENGTH - the maximum length of a complete pathname.
  175.  * FS_MAX_NAME_LENGTH - is the maximum length of one component of a name.
  176.  */
  177. #define    FS_BLOCK_SIZE        4096
  178. #define FS_MAX_PATH_NAME_LENGTH    1024
  179. #define FS_MAX_NAME_LENGTH    255
  180.  
  181.  
  182.  
  183. /*
  184.  * Open stream flags that are passed to Fs_Open from user programs.  These
  185.  *    flags are kept in a kernel data structure along with some other
  186.  *    flags used by the operating system internally.  This fact is only
  187.  *    important to pseudo-device and pseudo-file-system servers which
  188.  *    may see the other flags, which are defined in <kernel/fs.h>.
  189.  *
  190.  *    FS_READ        - open the file for read access.
  191.  *    FS_WRITE    - open the file for write access, can be combined
  192.  *              with FS_READ
  193.  *    FS_EXECUTE    - open the file for execute access.  This mode is used
  194.  *              by the kernel when opening a.out files.  It can
  195.  *              be used to limit the open to executables files.
  196.  *    FS_APPEND    - open for append mode. All writes get appended to the
  197.  *              end of the file regardless of the file pointer.
  198.  *    FS_CLOSE_ON_EXEC - close the stream when the process execs.
  199.  *    FS_NON_BLOCKING - I/O operations don't block (if applicable) but
  200.  *              instead return FS_WOULD_BLOCK.
  201.  *    FS_CREATE    - create the file if it doesn't exist.
  202.  *    FS_TRUNC    - truncate the file to zero length.
  203.  *    FS_EXCLUSIVE    - If specified with FS_CREATE the open/create will
  204.  *              fail if the file already exists.
  205.  *    FS_NAMED_PIPE_OPEN - Open as a named pipe. (NOT IMPLEMENTED)
  206.  *    FS_PDEV_MASTER     - Caller wants to be master of the pseudo-device.
  207.  *    FS_PFS_MASTER     - Caller wants to be server of the pseudo-filesystem.
  208.  */
  209. #define FS_USER_FLAGS              0xfff
  210. #define FS_READ                  0x001
  211. #define FS_WRITE              0x002
  212. #define FS_EXECUTE              0x004
  213. #define FS_APPEND              0x008
  214. #define FS_CLOSE_ON_EXEC        0x010
  215. #define FS_PDEV_MASTER            0x020
  216. #define FS_NAMED_PIPE_OPEN        0x040
  217. #define    FS_PFS_MASTER            0x080
  218. #define FS_NON_BLOCKING            0x100
  219. #define FS_CREATE              0x200
  220. #define FS_TRUNC              0x400
  221. #define FS_EXCLUSIVE              0x800
  222. /*            More high order bits are defined in <kernel/fs.h> !! */
  223.  
  224. /*
  225.  * Flags for Fs_Select:
  226.  *
  227.  *    FS_READABLE    - Does the stream have data that can be read?
  228.  *    FS_WRITABLE    - Can data be written to the stream?
  229.  *    FS_EXCEPTION    - Are there any exception conditions that have
  230.  *              raised for the stream? (e.g. out-of-band data).
  231.  */
  232.  
  233. #define FS_READABLE    FS_READ
  234. #define FS_WRITABLE    FS_WRITE
  235. #define FS_EXCEPTION    FS_EXECUTE
  236. #define FS_EXCEPTABLE    FS_EXCEPTION
  237.  
  238.  
  239.  
  240. /*
  241.  * The Fs_Attributes type is the information returned about a file
  242.  * from the Fs_GetAttributes and Fs_GetAttributesID system calls.
  243.  * This struct is also the input parameter for the Fs_SetAttributes
  244.  * and Fs_SetAttributesID system calls.
  245.  */
  246. typedef struct Fs_Attributes {
  247.     int    serverID;        /* Host ID of file server */
  248.     int domain;            /* Server-relative domain number of the file */
  249.     int fileNumber;        /* Domain-relative file number */
  250.     int type;            /* File types defined below */
  251.     int size;            /* Number of bytes in the file */
  252.     int numLinks;        /* Number of directory references to the file */
  253.     unsigned int permissions;    /* Permission bits defined below */
  254.     int uid;            /* User ID of file's owner */
  255.     int gid;            /* ID of file's owning group */
  256.     int devServerID;        /* ID of device server */
  257.     int devType;        /* Type of the device */
  258.     int devUnit;        /* Interpreted by the device driver */
  259.     Time createTime;        /* Time of the files creation */
  260.     Time accessTime;        /* Time of last access to the file */
  261.     Time descModifyTime;    /* Time the file descriptor was last modified */
  262.     Time dataModifyTime;    /* Time the file's data was last modified */
  263.     int  blocks;        /* The number of blocks taken by the file */
  264.     int  blockSize;        /* The size of each block */
  265.     int    version;        /* This is incremented when file is written */
  266.     int userType;        /* User defined file type */
  267.     int pad[4];            /* Reserved */
  268. } Fs_Attributes;
  269.  
  270. /*
  271.  * The following are values for the fileOrLink argument to Fs_Set/GetAttributes.
  272.  *    FS_ATTRIB_LINK    Get the attributes of the named link, not of the
  273.  *        file the link refers to.
  274.  *    FS_ATTRIB_FILE    Get the attributes of the name file.  If the last
  275.  *        component of the file name is a link then use the file
  276.  *        to which the link refers.
  277.  */
  278. #define FS_ATTRIB_LINK            1
  279. #define FS_ATTRIB_FILE            2
  280.  
  281. /*
  282.  * The following are values for the flags passed to Fs_SetAttr and Fs_SetAttrID
  283.  *    FS_SET_ALL_ATTRS - Attempt to set all settable attributes (see below)
  284.  *    FS_SET_TIMES    - Set data modify and file access times.
  285.  *    FS_SET_MODE    - Set the permission mode bits of the file.
  286.  *    FS_SET_OWNER    - Set the owner and group owner of a file.
  287.  *    FS_SET_FILE_TYPE - Set the user-defined file type of a file.
  288.  *    FS_SET_DEVICE    - Set device attributes - server, type, unit
  289.  */
  290. #define FS_SET_ALL_ATTRS    0x1F
  291. #define FS_SET_TIMES        0x01
  292. #define FS_SET_MODE        0x02
  293. #define FS_SET_OWNER        0x04
  294. #define FS_SET_FILE_TYPE    0x08
  295. #define FS_SET_DEVICE        0x10
  296.  
  297. /*
  298.  * FS_LOCALHOST_ID is used as the device server ID for generic devices,
  299.  * those expected to exist on all hosts.  It is also used in the kernel
  300.  * when the "ioServerID" is the local host.
  301.  */
  302. #define FS_LOCALHOST_ID        -1
  303.  
  304. /*
  305.  * File types kept in FsFileDescriptors on disk:
  306.  *    FS_FILE            ordinary disk file
  307.  *    FS_DIRECTORY        file used to implement the directory stucture
  308.  *    FS_SYMBOLIC_LINK    regular file used to implement links
  309.  *    FS_REMOTE_LINK        symbolic link used to mark the top of a domain
  310.  *    FS_DEVICE        Placeholder for peripheral device
  311.  *    FS_REMOTE_DEVICE    not used
  312.  *    FS_LOCAL_PIPE        Temporary half-duplex pipe
  313.  *    FS_NAMED_PIPE        Persistent half-duplex pipe (not implemented)
  314.  *    FS_PSEUDO_DEV        Full duplex communication to a user process
  315.  *    FS_PSEUDO_FS        Marks a domain controlled by a user process
  316.  *    FS_XTRA_FILE        Extra file type used to stage the
  317.  *                (re)implementation of standard file types
  318.  */
  319.  
  320. #define    FS_FILE                0
  321. #define    FS_DIRECTORY            1
  322. #define    FS_SYMBOLIC_LINK        2
  323. #define    FS_REMOTE_LINK            3
  324. #define    FS_DEVICE            4
  325. #define    FS_REMOTE_DEVICE        5
  326. #define    FS_LOCAL_PIPE            6
  327. #define    FS_NAMED_PIPE            7
  328. #define    FS_PSEUDO_DEV            8
  329. #define FS_PSEUDO_FS            9
  330. #define FS_XTRA_FILE            10
  331.  
  332.  
  333. /*
  334.  * User-defined file types.  A number of types are standardized, but others
  335.  * may be defined by the user.
  336.  *
  337.  *     FS_USER_TYPE_UNDEFINED        - no type set
  338.  *     FS_USER_TYPE_TMP              - temporary file
  339.  *     FS_USER_TYPE_SWAP             - swap file
  340.  *     FS_USER_TYPE_OBJECT           - ".o" file
  341.  *     FS_USER_TYPE_BINARY           - executable
  342.  *     FS_USER_TYPE_OTHER           - file that doesn't correspond to any
  343.  *                      specific type.  This is distinct from
  344.  *                      undefined, which says the type is
  345.  *                      uninitialized and may be inferred by
  346.  *                      parent directory or file name.
  347.  */
  348. #define FS_USER_TYPE_UNDEFINED  0
  349. #define FS_USER_TYPE_TMP        1
  350. #define FS_USER_TYPE_SWAP    2
  351. #define FS_USER_TYPE_OBJECT    3
  352. #define FS_USER_TYPE_BINARY    4
  353. #define FS_USER_TYPE_OTHER    5
  354.  
  355.  
  356. /*
  357.  * The Fs_FileID and Fs_UserIDs types are exported to user-level so that
  358.  * pseudo-filesystem servers can understand the arguments to lookup operations
  359.  * that are defined in fsNameOps.h
  360.  *
  361.  * Fs_FileID - Uniquely identify a filesystem object.  A type is the first
  362.  *    field, the hostID of the server is next, and the remaining fields 
  363.  *    are interpreted by the implementation of that type of filesystem object
  364.  *    (ie. files, devices, pipes, pseudo-devices, etc.)
  365.  *    A global hash table of filesystem objects, (called "handles")
  366.  *    is maintained with this Fs_FileID as the hash key.
  367.  */
  368. typedef struct Fs_FileID {
  369.     int        type;        /* Defined in kernel fsio.h (stream types).
  370.                  * Used in I/O switch, and implicitly
  371.                  * indicates what kind of structure follows
  372.                  * the FsHandleHeader in the Handle. */
  373.     int        serverID;    /* Host that controls the object.  (This would
  374.                  * have to be a multi-cast ID for objects
  375.                  * that support replication.) */
  376.     int        major;        /* First type specific identifier. */
  377.     int        minor;        /* Second type sepcific identifier. */
  378. } Fs_FileID;            /* 16 BYTES */
  379.  
  380. /*
  381.  *    The FS_NUM_GROUPS constant limits the number of group IDs that
  382.  *    are used even though the proc table supports a variable number.
  383.  */
  384. #define FS_NUM_GROUPS    8
  385.  
  386. typedef struct Fs_UserIDs {
  387.     int user;            /* Indicates effective user ID */
  388.     int numGroupIDs;        /* Number of valid entries in groupIDs */
  389.     int group[FS_NUM_GROUPS];    /* The set of groups the user is in */
  390. } Fs_UserIDs;            /* 40 BYTES */
  391.  
  392.  
  393.  
  394.  
  395. /*
  396.  * Generic IO Control operations.
  397.  *    IOC_REPOSITION        Reposition the current offset into the file.
  398.  *    IOC_GET_FLAGS        Return the flags associated with the stream.
  399.  *    IOC_SET_FLAGS        Set all the flags for the stream.
  400.  *    IOC_SET_BITS        Set some of the flags for the stream.
  401.  *    IOC_CLEAR_BITS        Clear some of the flags for the stream.
  402.  *    IOC_TRUNCATE        Truncate the stream to a given length.
  403.  *    IOC_LOCK        Lock the stream or underlying file.
  404.  *    IOC_UNLOCK        Unlock the stream.
  405.  *    IOC_NUM_READABLE    Return the number of bytes available.
  406.  *    IOC_GET_OWNER        Return the process or family that gets signals.
  407.  *    IOC_SET_OWNER        Set the process or family that gets signals.
  408.  *    IOC_MAP            Map the stream into the processes VM
  409.  *    IOC_PREFIX        Get the prefix under which the stream was
  410.  *                opened.  This is useful if a server is exporting
  411.  *                a domain under more than one name.  The getwd()
  412.  *                library call uses this feature.
  413.  *    IOC_WRITE_BACK        Write back any cached stream data.
  414.  *    IOC_MMAP_INFO        Provide server with information on
  415.  *                VM memory mapping.
  416.  *
  417.  *    IOC_GENERIC_LIMIT    This is the maximum IOC number that can be
  418.  *                used for the generic I/O controls supported
  419.  *                by the kernel.  Device drivers define I/O
  420.  *                control numbers above this limit.  This limit
  421.  *                is used in the kernel to optimize handling
  422.  *                generic vs. non-generic I/O controls.
  423.  */
  424.  
  425. #define    IOC_REPOSITION            1
  426. #define    IOC_GET_FLAGS            2
  427. #define IOC_SET_FLAGS            3
  428. #define IOC_SET_BITS            4
  429. #define IOC_CLEAR_BITS            5
  430. #define IOC_TRUNCATE            6
  431. #define IOC_LOCK            7
  432. #define IOC_UNLOCK            8
  433. #define IOC_NUM_READABLE        9
  434. #define IOC_GET_OWNER            10
  435. #define IOC_SET_OWNER            11
  436. #define IOC_MAP                12
  437. #define IOC_PREFIX            13
  438. #define IOC_WRITE_BACK            14
  439. #define    IOC_MMAP_INFO            15
  440. #define IOC_GENERIC_LIMIT        ((1<<16)-1)
  441.  
  442. /*
  443.  * Maximum number of bytes that be copied in on an iocontrol.
  444.  */
  445.  
  446. #define    IOC_MAX_BYTES    4096
  447.  
  448.  
  449. /*
  450.  * IOC_REPOSITION - reposition the file access position.
  451.  */
  452.  
  453. typedef struct Ioc_RepositionArgs {
  454.     int base;    /* Base at which to start reposition: defines below */
  455.     int offset;    /* Offset from base */
  456. } Ioc_RepositionArgs;
  457.  
  458. /*
  459.  * Base argument definitions:
  460.  *    IOC_BASE_ZERO        base is the beginning of the file.
  461.  *    IOC_BASE_CURRENT    base is the current position in the file.
  462.  *    IOC_BASE_EOF        base is the end of the file.
  463.  */
  464.  
  465. #define IOC_BASE_ZERO        0
  466. #define IOC_BASE_CURRENT    1
  467. #define IOC_BASE_EOF        2
  468.  
  469.  
  470.  
  471. /*
  472.  *    IOC_GET_FLAGS        Return the flags associated with the stream.
  473.  *    IOC_SET_FLAGS        Set all the flags for the stream.
  474.  *    IOC_SET_BITS        Set some of the flags for the stream.
  475.  *    IOC_CLEAR_BITS        Clear some of the flags for the stream.
  476.  *
  477.  *    A few of the low order bits in the flags field are reserved
  478.  *    for use by the kernel.  The rest bits are left for interpretation
  479.  *    by the (pseudo) device driver.
  480.  *        IOC_APPEND    Do append mode writes to the stream
  481.  *        IOC_NON_BLOCKING Do not block if I/O is not ready
  482.  *        IOC_ASYNCHRONOUS Dispatch I/O and signal when complete
  483.  *                 This is not implemented yet, 6/87
  484.  *        IOC_CLOSE_ON_EXEC This forces the stream to be closed when
  485.  *                the process execs another program.
  486.  *        IOC_READ    Stream is open for reading.
  487.  *        IOC_WRITE    Stream is open for writing.
  488.  */
  489.  
  490. #define IOC_GENERIC_FLAGS    0xFF
  491. #define    IOC_APPEND        0x01
  492. #define IOC_NON_BLOCKING    0x02
  493. #define IOC_ASYNCHRONOUS    0x04
  494. #define IOC_CLOSE_ON_EXEC    0x08
  495. #define IOC_READ        0x10
  496. #define IOC_WRITE        0x20
  497.  
  498.  
  499. /*
  500.  *    IOC_LOCK        Lock the stream or underlying file.
  501.  *    IOC_UNLOCK        Unlock the stream.
  502.  */
  503. typedef struct Ioc_LockArgs {
  504.     int        flags;        /* IOC_LOCK_EXCLUSIVE, no other locks allowed
  505.                  * IOC_LOCK_SHARED, can have many of these,
  506.                  *    but no exclusive locks 
  507.                  * IOC_LOCK_NO_BLOCK, don't block if the lock
  508.                  *    can't be obtained, return FS_WOUD_BLOCK
  509.                  */
  510.     /*
  511.      * The following fields are set by the kernel and used by
  512.      * lower levels to notify when the lock is obtainable.  Pseudo-device
  513.      * masters use IOC_PDEV_LOCK_READY IOControl to do this notify.
  514.      */
  515.     int        hostID;        /* Set by the kernel */
  516.     Proc_PID    pid;        /* Set by the kernel */
  517.     int        token;        /* Set by the kernel */
  518. } Ioc_LockArgs;
  519.  
  520. #define IOC_LOCK_SHARED            0x1
  521. #define IOC_LOCK_EXCLUSIVE        0x2
  522. #define IOC_LOCK_NO_BLOCK        0x8
  523.  
  524. /*
  525.  *    IOC_GET_OWNER        Return the process or family that gets signals.
  526.  *    IOC_SET_OWNER        Set the process or family that gets signals.
  527.  */
  528. typedef struct Ioc_Owner {
  529.     Proc_PID    id;        /* Process or Family ID */
  530.     int        procOrFamily;    /* IOC_OWNER_FAMILY or IOC_OWNER_PROC */
  531. } Ioc_Owner;
  532.  
  533. #define IOC_OWNER_FAMILY    0x1
  534. #define IOC_OWNER_PROC        0x2
  535.  
  536. /*
  537.  *    IOC_MAP            Map the stream into the processes VM
  538.  */
  539. typedef struct Ioc_MapArgs {
  540.     int        numBytes;
  541.     Address    address;
  542. } Ioc_MapArgs;
  543.  
  544. /*
  545.  *    IOC_PREFIX        Return prefix under which stream was opened.
  546.  */
  547. typedef struct Ioc_PrefixArgs {
  548.     char    prefix[FS_MAX_PATH_NAME_LENGTH];  /* Set by kernel */
  549. } Ioc_PrefixArgs;
  550.  
  551. /*
  552.  *    IOC_WRITE_BACK        Write back the cached data of a file.
  553.  *                Although the arguments are in terms
  554.  *                of bytes, the cache will block align
  555.  *                the write-back so the bytes are fully
  556.  *                included in the blocks written back.
  557.  */
  558. typedef struct Ioc_WriteBackArgs {
  559.     int        firstByte;    /* Index of first byte to write back */
  560.     int        lastByte;    /* Index of last byte to write back */
  561.     Boolean    shouldBlock;    /* If TRUE, call blocks until write back done */
  562. } Ioc_WriteBackArgs;
  563.  
  564. /*
  565.  *    IOC_MMAP_INFO        Give information to the server that a
  566.  *                client is mapping a stream into memory.
  567.  */
  568. typedef struct Ioc_MmapInfoArgs {
  569.     int        isMapped;    /* 1 if mapping, 0 if unmapping. */
  570.     int        clientID;    /* ID of the requesting client. */
  571. } Ioc_MmapInfoArgs;
  572.  
  573. /*
  574.  * A mask of 9 permission bits is used to define the permissions on a file.
  575.  * A mask like this occurs in the FileDescriptor for a file.  A mask like
  576.  * this is also part of the state of each process.  It defines the maximal
  577.  * set of permissions that a newly created file can have. The following
  578.  * define the various permission bits.
  579.  *    FS_OWNER_{READ|WRITE|EXEC}    A process with a UID that matches the
  580.  *            file's UID has {READ|WRITE|EXEC} permission on the file.
  581.  *    FS_GROUP_{READ|WRITE|EXEC}    A process with one of its group IDS
  582.  *            that matches the file's GID has permission...
  583.  *    FS_WORLD_{READ|WRITE|EXEC}    Any process has permission if WORLD
  584.  *            permission bits are set.
  585.  */
  586. #define FS_OWNER_READ            00400
  587. #define FS_OWNER_WRITE            00200
  588. #define FS_OWNER_EXEC            00100
  589. #define FS_GROUP_READ            00040
  590. #define FS_GROUP_WRITE            00020
  591. #define FS_GROUP_EXEC            00010
  592. #define FS_WORLD_READ            00004
  593. #define FS_WORLD_WRITE            00002
  594. #define FS_WORLD_EXEC            00001
  595.  
  596. /*
  597.  * Other permission bits:
  598.  *    FS_SET_UID    This bit set on a program image or shell script
  599.  *        causes the execed process to take on the user id of
  600.  *        the file.  (Thanks to Dennis Ritchie for this great idea.)
  601.  *    FS_SET_GID    As above, but for the group id.
  602.  */
  603. #define FS_SET_UID            04000
  604. #define FS_SET_GID            02000
  605.  
  606.  
  607.  
  608. /*
  609.  * Values of the mode argument to the Fs_CheckAccess system call.
  610.  *    FS_EXISTS    does the file exists (can the caller see it)
  611.  *    FS_READ        does the caller have read access
  612.  *    FS_WRITE    does the caller have write access
  613.  *    FS_EXECUTE    does the caller have execution access
  614.  */
  615. #define FS_EXISTS        0x0
  616.  
  617. /*
  618.  * Flag to Fs_GetNewID call that says choose any new stream ID.
  619.  */
  620. #define FS_ANYID            -1
  621.  
  622. /*
  623.  * The Fs_AttachDisk system call takes flags that affect just what is
  624.  * done with the disk partition and the associated prefix.
  625.  *    FS_ATTACH_READ_ONLY    Set the disk up to be read only.
  626.  *    FS_DETACH        The disk becomes inaccessible.  Any modified
  627.  *                filesystem data is flushed first.
  628.  *    FS_ATTACH_LOCAL        The disk is attached locally and not exported
  629.  *    FS_DEFAULT_DOMAIN    The domain is being attached by the kernel
  630.  *                during boot as the default.
  631.  *
  632.  */
  633. #define FS_ATTACH_READ_ONLY        0x1
  634. #define FS_DETACH            0x2
  635. #define FS_ATTACH_LOCAL            0x4
  636. #define FS_DEFAULT_DOMAIN        0x8
  637.  
  638. typedef struct Fs_TwoPaths {
  639.     int        pathLen1;    /* Length of the first path, including null */
  640.     int        pathLen2;    /* Length of the second path, including null */
  641.     char     *path1;        /* First pathname */
  642.     char     *path2;        /* Second pathname */
  643. } Fs_TwoPaths;
  644.  
  645. /*
  646.  * Information about a file system domain (volume).
  647.  */
  648. typedef struct {
  649.     int    maxKbytes;        /* Total Kbytes in the domain.  The allocation
  650.                  * routine might reserve some (%10) of this */
  651.     int    freeKbytes;        /* The number of available blocks.  This
  652.                  * reflects any reservations made by the
  653.                  * allocator.  If this is positive, blocks
  654.                  * are available. */
  655.     int    maxFileDesc;        /* The total number of files that can be
  656.                  * created in the domain. */
  657.     int    freeFileDesc;        /* The number of free file descriptors */
  658.     int blockSize;        /* Bytes per block */
  659.     int optSize;        /* Optimal transfer size, in bytes */
  660. } Fs_DomainInfo;
  661.  
  662.  
  663. /*
  664.  * User visible prefix table entry.  This is used by the routine that
  665.  * copies individual entries out to user programs.
  666.  */
  667. #define FS_USER_PREFIX_LENGTH    64
  668. #define FS_NO_SERVER        0
  669. typedef struct Fs_Prefix {
  670.     int serverID;        /* From FsFileID of prefix, FS_NO_SERVER if 
  671.                  * no handle */
  672.     int domain;            /* ditto */
  673.     int fileNumber;        /* ditto */
  674.     int version;        /* ditto */
  675.     int flags;            /* Defined below */
  676.     char prefix[FS_USER_PREFIX_LENGTH];
  677.     Fs_DomainInfo domainInfo;    /* Information about the domain. */
  678. } Fs_Prefix;
  679.  
  680. #ifndef FS_EXPORTED_PREFIX
  681. #define    FS_EXPORTED_PREFIX        0x1
  682. #define    FS_IMPORTED_PREFIX        0x2
  683. #define    FS_LOCAL_PREFIX            0x4
  684. #endif
  685.  
  686.  
  687. /*
  688.  * The Fs_ReadVector and Fs_WriteVector system calls take an array of
  689.  * I/O vectors. This allows data to be read to or written from non-contiguous
  690.  * areas of memory.
  691.  */
  692. typedef struct {
  693.     int        bufSize;    /* Size in bytes of the buffer */
  694.     Address    buffer;        /* For Fs_WriteVector, data to be written.
  695.                  * For Fs_ReadVector, place where read data 
  696.                  * is stored. */
  697. } Fs_IOVector;
  698.  
  699.  
  700. /*
  701.  * The structure below is use for creating devices with Fs_MakeDevice.
  702.  * It's also used internally by the kernel to hold the information passed
  703.  * to device specific routines so they can operate on their particular device.
  704.  */
  705. typedef struct Fs_Device {
  706.     int        serverID;    /* The host ID of the server that controls
  707.                  * the device. */
  708.     int        type;        /* The type of device.  This field is used to
  709.                  * index into an operation switch */
  710.     int        unit;        /* Type dependent unit specification. The
  711.                  * interpretation is up to the device driver */
  712.     ClientData    data;        /* Device type dependent data. This can be set
  713.                  * during the device open routine and should
  714.                  * be cleaned up in the device close routine. */
  715. } Fs_Device;
  716.  
  717. /*
  718.  * Definitions for the FS dispatcher library.
  719.  */
  720. typedef ClientData Fs_TimeoutHandler;
  721.  
  722. extern void            Fs_Dispatch();
  723. extern void            Fs_EventHandlerCreate();
  724. extern void             Fs_EventHandlerDestroy();
  725. extern ClientData         Fs_EventHandlerData();
  726. extern ClientData         Fs_EventHandlerChangeData();
  727. extern char            *Fs_GetTempName();
  728. extern int            Fs_GetTempFile();
  729. extern int                  Fs_IOControl();
  730. extern Boolean            Fs_IsATerm();
  731. extern Fs_TimeoutHandler    Fs_TimeoutHandlerCreate();
  732. extern void             Fs_TimeoutHandlerDestroy();
  733.  
  734. extern int                  Ioc_ClearBits();
  735. extern int                  Ioc_GetFlags();
  736. extern int                  Ioc_GetOwner();
  737. extern int                  Ioc_Lock();
  738. extern int                  Ioc_Map();
  739. extern int                  Ioc_NumReadable();
  740. extern int                  Ioc_SetBits();
  741. extern int                  Ioc_Reposition();
  742. extern int                  Ioc_SetFlags();
  743. extern int                  Ioc_SetOwner();
  744. extern int                  Ioc_Truncate();
  745. extern int                  Ioc_Unlock();
  746. extern int                  Ioc_WriteBack();
  747.  
  748. #endif /* _FS_H */
  749. @
  750.  
  751.  
  752. 1.20
  753. log
  754. @Fs_FileID types are defined in fsio.h, not user/fs.h.
  755. @
  756. text
  757. @d16 1
  758. a16 1
  759.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.19 90/10/11 18:55:01 rab Exp Locker: kupfer $ SPRITE (Berkeley)
  760. d357 2
  761. d366 2
  762. @
  763.  
  764.  
  765. 1.20.1.1
  766. log
  767. @Branch for Sprite server changes.
  768. @
  769. text
  770. @d16 1
  771. a16 1
  772.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.20 91/05/20 17:32:40 kupfer Exp $ SPRITE (Berkeley)
  773. @
  774.  
  775.  
  776. 1.19
  777. log
  778. @Changed definitions for major and minor so that this file can be
  779. used to compile stuff under unix, which defines major and minor as
  780. macros in types.h
  781. @
  782. text
  783. @d16 1
  784. a16 1
  785.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.18 90/09/13 11:10:03 jhh Exp Locker: rab $ SPRITE (Berkeley)
  786. d240 4
  787. a243 3
  788.     int        type;        /* Defined below. Used in I/O switch, and
  789.                  * implicitly indicates what kind of structure
  790.                  * follows the FsHandleHeader in the Handle. */
  791. @
  792.  
  793.  
  794. 1.18
  795. log
  796. @fixed include of procTypes.h
  797. @
  798. text
  799. @d16 1
  800. a16 1
  801.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.17 90/05/03 13:03:02 rab Exp Locker: jhh $ SPRITE (Berkeley)
  802. d33 2
  803. a34 1
  804. #if !defined(__STDC__) && defined(_TYPES)
  805. d36 2
  806. d39 2
  807. a40 1
  808. #endif /* ! __STDC__ && _TYPES */
  809. @
  810.  
  811.  
  812. 1.17
  813. log
  814. @Added declarations for library procedures.
  815. @
  816. text
  817. @d16 1
  818. a16 1
  819.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.16 90/02/20 18:13:46 jhh Exp Locker: rab $ SPRITE (Berkeley)
  820. d23 1
  821. a23 1
  822. #include <proc.h>
  823. @
  824.  
  825.  
  826. 1.16
  827. log
  828. @Added FS_DEFAULT_DOMAIN
  829. @
  830. text
  831. @d16 1
  832. a16 1
  833.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.15 90/01/16 17:57:38 brent Exp Locker: jhh $ SPRITE (Berkeley)
  834. d19 2
  835. a20 2
  836. #ifndef _FSUSER
  837. #define _FSUSER
  838. d584 25
  839. a608 11
  840. extern void        Fs_Dispatch();
  841. extern void        Fs_EventHandlerCreate();
  842. extern void         Fs_EventHandlerDestroy();
  843. extern ClientData     Fs_EventHandlerData();
  844. extern ClientData     Fs_EventHandlerChangeData();
  845. extern Fs_TimeoutHandler Fs_TimeoutHandlerCreate();
  846. extern void         Fs_TimeoutHandlerDestroy();
  847.  
  848. extern Boolean        Fs_IsATerm();
  849. extern char        *Fs_GetTempName();
  850. extern int        Fs_GetTempFile();
  851. d610 1
  852. a610 1
  853. #endif /* _FSUSER */
  854. @
  855.  
  856.  
  857. 1.15
  858. log
  859. @Patched up definitions of major() and minor() macros
  860. so they do not conflict with the major and minor fields
  861. of the Fs_FileID struct.
  862. @
  863. text
  864. @d16 1
  865. a16 1
  866.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.14 89/11/09 13:27:41 shirriff Exp Locker: brent $ SPRITE (Berkeley)
  867. d491 3
  868. d498 2
  869. @
  870.  
  871.  
  872. 1.14
  873. log
  874. @Change IOC_MAP back to old def.  Added IOC_MMAP_INFO.
  875. @
  876. text
  877. @d16 1
  878. a16 1
  879.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.13 89/08/30 08:21:09 brent Exp Locker: shirriff $ SPRITE (Berkeley)
  880. d27 5
  881. a31 5
  882.  * the names of fields in a structure defined in fs.h.  Unfortunately, cpp
  883.  * on the sun4 expands the macros inside the structure field names, so I
  884.  * undefine and redefine them here around the inclusion of fs.h, so that
  885.  * source files that include both files don't complain.  Of course, this
  886.  * means they have to include them in the correct order, but they all do.
  887. d33 1
  888. a33 1
  889. #if (defined (sun4) || defined (mips)) && defined(_TYPES)
  890. d36 1
  891. a36 1
  892. #endif /* (sun4 || mips) && _TYPES */
  893. a589 5
  894.  
  895. #if defined (sun4) && defined (_TYPES)
  896. #define major(x)        ((int)(((unsigned)(x)>>8)&0377))
  897. #define minor(x)        ((int)((x)&0377))
  898. #endif /* sun4 && _TYPES */
  899. @
  900.  
  901.  
  902. 1.13
  903. log
  904. @Added IOC_WRITE_BACK
  905. @
  906. text
  907. @d16 1
  908. a16 1
  909.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.12 89/07/18 13:54:41 jhh Exp Locker: brent $ SPRITE (Berkeley)
  910. d280 2
  911. d305 1
  912. d402 2
  913. a403 2
  914.     int    numBytes;
  915.     Address address;
  916. d426 8
  917. @
  918.  
  919.  
  920. 1.12
  921. log
  922. @added IOC_PREFIX ioctl
  923. @
  924. text
  925. @d16 1
  926. a16 1
  927.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.11 89/07/10 14:27:05 nelson Exp Locker: jhh $ SPRITE (Berkeley)
  928. d276 4
  929. a279 1
  930.  *                opened.
  931. d302 1
  932. d409 13
  933. @
  934.  
  935.  
  936. 1.11
  937. log
  938. @Added mips ifdef same as sun4.
  939. @
  940. text
  941. @d16 1
  942. a16 1
  943.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.10 89/06/23 11:29:42 rab Exp Locker: nelson $ SPRITE (Berkeley)
  944. d275 2
  945. d298 1
  946. d398 7
  947. @
  948.  
  949.  
  950. 1.10
  951. log
  952. @*** empty log message ***
  953. @
  954. text
  955. @d16 1
  956. a16 1
  957.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.9 89/06/08 12:49:44 brent Exp Locker: rab $ SPRITE (Berkeley)
  958. d33 1
  959. a33 1
  960. #if defined (sun4) && defined(_TYPES)
  961. d36 1
  962. a36 1
  963. #endif /* sun4 && _TYPES */
  964. @
  965.  
  966.  
  967. 1.9
  968. log
  969. @Changed Fs_DomainInfo to include a blockSize and an
  970. optimal transfer size.
  971. @
  972. text
  973. @d16 1
  974. a16 1
  975.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.8 89/04/09 10:20:30 brent Exp Locker: brent $ SPRITE (Berkeley)
  976. d558 1
  977. a558 1
  978. #endif _FSUSER
  979. @
  980.  
  981.  
  982. 1.8
  983. log
  984. @Updated the comment about the Open flags.  Pseudo-device and
  985. pseudo-file-system servers will see additional kernel-flags that
  986. are defined in <kernel/fs.h>
  987. @
  988. text
  989. @d16 1
  990. a16 1
  991.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.7 89/02/27 17:51:45 mgbaker Exp Locker: brent $ SPRITE (Berkeley)
  992. d100 3
  993. a102 3
  994. #define FS_READABLE    0x1
  995. #define FS_WRITABLE    0x2
  996. #define FS_EXCEPTION    0x4
  997. d465 1
  998. a465 1
  999.  * Information about a domain.
  1000. d468 11
  1001. a478 4
  1002.     int    maxKbytes;
  1003.     int    freeKbytes;
  1004.     int    maxFileDesc;
  1005.     int    freeFileDesc;
  1006. d487 1
  1007. d489 2
  1008. a490 1
  1009.     int serverID;        /* From FsFileID of prefix, -1 if no handle */
  1010. @
  1011.  
  1012.  
  1013. 1.7
  1014. log
  1015. @Added hack to allow sun4 cpp to work with inclusion of both fs.h
  1016. and types.h.  See fs.h for details.
  1017. @
  1018. text
  1019. @d16 1
  1020. a16 1
  1021.  * $Header: /sprite/src/lib/include/RCS/fs.h,v 1.6 88/10/14 10:24:35 brent Exp Locker: mgbaker $ SPRITE (Berkeley)
  1022. d51 5
  1023. a55 1
  1024.  * File descriptor flags that are passed to Fs_Open.
  1025. d89 1
  1026. @
  1027.  
  1028.  
  1029. 1.6
  1030. log
  1031. @Moved Fs_FileID and Fs_UserIDs here because of pseudo-filesystems
  1032. @
  1033. text
  1034. @d16 1
  1035. a16 1
  1036.  * $Header: fs.h,v 1.5 88/09/30 08:29:07 brent Exp $ SPRITE (Berkeley)
  1037. d26 13
  1038. d538 5
  1039. @
  1040.  
  1041.  
  1042. 1.5
  1043. log
  1044. @Added FS_PFS_MASTER flag for pseudo-filesystems
  1045. @
  1046. text
  1047. @d16 1
  1048. a16 1
  1049.  * $Header: fs.h,v 1.4 88/08/12 16:03:37 brent Exp $ SPRITE (Berkeley)
  1050. d203 38
  1051. @
  1052.  
  1053.  
  1054. 1.4
  1055. log
  1056. @Added Fs_SetAttr flag definitions
  1057. @
  1058. text
  1059. @d16 1
  1060. a16 1
  1061.  * $Header: fs.h,v 1.3 88/06/27 14:51:18 ouster Exp $ SPRITE (Berkeley)
  1062. d55 3
  1063. a57 4
  1064.  *    FS_NAMED_PIPE_OPEN - Open as a named pipe.
  1065.  *    FS_MASTER     - Caller is master of the pseudo-device being opened.
  1066.  *    FS_NEW_MASTER     - Caller is master of the pseudo-device being opened.
  1067.  *              This is for the new version of pseudo-devices.
  1068. d65 1
  1069. a65 1
  1070. #define FS_NEW_MASTER            0x020
  1071. d67 1
  1072. a67 1
  1073. #define    FS_MASTER            0x080
  1074. d155 2
  1075. a156 2
  1076.  *    FS_FILE        ordinary disk file
  1077.  *    FS_DIRECTORY    regular file used to implement the directory stucture
  1078. d162 1
  1079. a162 1
  1080.  *    FS_NAMED_PIPE        Persistent half-duplex pipe
  1081. @
  1082.  
  1083.  
  1084. 1.3
  1085. log
  1086. @Move Fs_Device from kernel/fs.h to fs.h.
  1087. @
  1088. text
  1089. @d16 1
  1090. a16 1
  1091.  * $Header: fs.h,v 1.2 88/06/21 16:38:46 ouster Exp $ SPRITE (Berkeley)
  1092. d130 16
  1093. @
  1094.  
  1095.  
  1096. 1.2
  1097. log
  1098. @Use "spriteTime.h" instead of "time.h" to avoid conflict with UNIX.
  1099. @
  1100. text
  1101. @d16 1
  1102. a16 1
  1103.  * $Header: fs.h,v 1.1 88/06/21 09:36:51 ouster Exp $ SPRITE (Berkeley)
  1104. d437 18
  1105. @
  1106.  
  1107.  
  1108. 1.1
  1109. log
  1110. @Initial revision
  1111. @
  1112. text
  1113. @d16 1
  1114. a16 1
  1115.  * $Header: fs.h,v 2.9 88/04/16 11:38:15 brent Exp $ SPRITE (Berkeley)
  1116. d22 2
  1117. a23 2
  1118. #include "time.h"
  1119. #include "proc.h"
  1120. @
  1121.